<template>
    <div>

        <form>
            账号：
            <input v-model="username" type="text"/>
            password：
            <input v-model="password" type="text"/>
        </form>

        <button @click="click1">login</button>
        <div>{{ token }}</div>
        <div>{{ info }}</div>
    </div>
</template>

<script lang="ts">
import axios from 'axios'
export default {
    data() {
        return {
            username:"",
            password:"",
            info: {},
            token: ""
        }
    },
    methods: {
        click1() {
            axios
                .post("http://localhost:8080/login", {
                    username: this.username,
                    password: this.password
                })
                .then((response) => {
                    this.token = response.data
                    this.getUserInfo()
                });
        },
        getUserInfo() {
            axios
                .get("http://localhost:8080/userinfo", {
                    headers: {
                        Token: this.token
                    }
                })
                .then((response) => (this.info = response.data));
        }
    },
};
</script>

<style>
</style>